<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let module = (function(){
            const moduleList = {};

            function define(name, modules, action){
                modules.map( (m,i)=>{
                    modules[i] = moduleList[m]
                } )

                moduleList[name] = action.apply(null, modules);
                // console.log(moduleList);

            }
            return {define}
        })()

        module.define("hd",[],function(){
            return {
                first(arr){
                    return arr[0]
                },
                max(arr,key){
                    return arr.sort( (a,b)=> b[key]-a[key] )[0];
                }
            };
        });

        module.define("lesson",["hd"],function(hd){
            console.log(hd)

            let data =[
                {name:"js", price:199},
                {name:"mysql", price:78}
            ];

            console.log(hd.max(data, 'price'))
        });
    </script>
</body>
</html>